<?php /*a:3:{s:61:"D:\laragon\www\Coupon\application\manage\view\coupon_add.html";i:1601363002;s:55:"D:\laragon\www\Coupon\application\manage\view\base.html";i:1596192950;s:64:"D:\laragon\www\Coupon\application\manage\view\public_upload.html";i:1591401853;}*/ ?>
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
	<meta name="renderer" content="webkit">
<title>后台管理系统</title>
<link rel="stylesheet" href="/static/public/awesome/css/font-awesome.min.css" />

<link rel="stylesheet" href="/static/public/layui/css/layui.css" />

<link rel="stylesheet" href="/static/public/kindeditor/themes/default/default.css" />
<link rel="stylesheet" href="/static/manage/css/style.css" />

	<link rel="stylesheet" href="/static/public/dist/zoomify.min.css">
	
<script src="/static/public/kindeditor/kindeditor-all.js"></script>
<script src="/static/public/kindeditor/lang/zh_CN.js"></script>
<script src="/static/public/ueditor/ueditor.config.js?t=<?php echo time();?>"></script>
<script src="/static/public/ueditor/ueditor.all.min.js"></script>
<script src="/static/public/ueditor/lang/zh-cn/zh-cn.js"></script>
</head>
<body>
<?php if($is_auth): ?>

<script language="javascript" type="text/javascript" src="/static/public/My97DatePicker/WdatePicker.js"></script>
<div class="g-main">
    <div class="m-main-title">
        <div class="m-container-fluid">
            <a href="<?php echo url('index/welcome'); ?>"><i class="icon icon-home"></i>首页</a>
            <span class="icon-angle-right"></span>
            <span>商城</span>
            <span class="icon-angle-right"></span>
            <span>优惠券管理</span>
            <span class="icon-angle-right"></span>
            <span>优惠券管理</span>
            <span class="icon-angle-right"></span>
            <span><?php echo !empty($info) ? '编辑'  :  '添加'; ?>优惠券</span>
            <a class="u-flush"><i class="icon-repeat"></i></a>
        </div>
    </div>
    <div class="m-main-content">
        <div class="m-container">
            <div class="m-form">
                <form class="layui-form" id="j_form">
                    <table class="m-table">
                        <tbody>
                            <tr>
                                <th colspan="2">优惠券信息</th>
                            </tr>
                            <tr>
                                <td width="15%"><label for="coupon_name">优惠券名称<em>*</em></label></td>
                                <td><input type="text" class="u-ipt u-ipt-longer" name="coupon_name" id="coupon_name" placeholder="请输入优惠券名称" value="<?php echo htmlentities($info['coupon_name']); ?>" /></td>
                            </tr>
                            <tr>
                                <td width="15%"><label for="description">优惠券描述<em>*</em></label></td>
                                <td><textarea name="description" id="description" style="width:100%;"><?php echo htmlentities($info['description']); ?></textarea></td>
                            </tr>
                            <tr>
                                <td><label for="">优惠券类别<em>*</em></label></td>
                                <td>
                                    <div class="lay-select m-select-def">
                                        <select name="class_id" lay-filter="category_id">
                                            <option value="0">请选择类别</option>
                                            <?php if(is_array($class) || $class instanceof \think\Collection || $class instanceof \think\Paginator): if( count($class)==0 ) : echo "" ;else: foreach($class as $key=>$v): ?>
                                            <option value="<?php echo htmlentities($v['id']); ?>"<?php if($info['class_id'] == $v['id']): ?> selected<?php endif; ?>><?php echo htmlentities($v['class_name']); ?></option>
                                            <?php endforeach; endif; else: echo "" ;endif; ?>
                                        </select>
                                    </div>
                                </td>
                            </tr>

                            <tr>
                                <td width="15%"><label>优惠券类型<em>*</em></label></td>
                                <td>
                                    <input type="radio" lay-filter="coupon_type" name="coupon_type" value="0" title="满减劵" <?php if(isset($info['coupon_type']) && ($info['coupon_type'] == 0)): ?> checked<?php endif; ?> />
                                    <input type="radio" lay-filter="coupon_type" name="coupon_type" value="1" title="抵用券" <?php if(isset($info['coupon_type']) && ($info['coupon_type'] == 1)): ?> checked<?php endif; ?> />
                                </td>
                            </tr>
                            <tr>
                                <td width="15%"><label for="limit_price">限制使用金额<em>*</em></label></td>
                                <td><input type="text" class="u-ipt u-ipt-small" name="limit_price" id="limit_price" placeholder="请输入限制使用金额" value="<?php echo htmlentities($info['limit_price']); ?>" <?php if($info['limit_price'] != ''): ?>readonly<?php endif; ?> /><span>元</span></td>
                            </tr>
                            <tr>
                                <td width="15%"><label for="offset_price">冲抵金额<em>*</em></label></td>
                                <td><input type="text" class="u-ipt u-ipt-small" name="offset_price" id="offset_price" placeholder="请输入冲抵金额" value="<?php echo htmlentities($info['offset_price']); ?>"  <?php if($info['offset_price'] != ''): ?>readonly<?php endif; ?>  /></td>
                            </tr>
                            <tr>
                                <td width="15%"><label for="offset_price">优惠券数量<em>*</em></label></td>
                                <td><input type="text" class="u-ipt u-ipt-small"  name="number" id="number" placeholder="请输入优惠券数量" value="<?php echo htmlentities($info['number']); ?>" <?php if($info['number'] != ''): ?>readonly<?php endif; ?> /></td>
                            </tr>
                            <tr>
                                <td width="15%"><label for="offset_price">剩余数量</label></td>
                                <td><input type="text" class="u-ipt u-ipt-small" name="surplus_number" readonly id="surplus_number" placeholder="" value="<?php echo htmlentities($info['surplus_number']); ?>" /></td>
                            </tr>
                            <tr>
                                <td width="15%"><label for="limit_price">有效期开始时间<em>*</em></label></td>
                                <td><input type="text" name="pbegin" class="u-ipt u-ipt-long" id="pbegin" placeholder="开始时间"  value="<?php echo !empty($info['pbegin']) ? date('Y-m-d',$info['pbegin'])  :  date('Y-m-d', time()); ?>" <?php if($info['pbegin'] != ''): ?>readonly<?php else: ?> onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"<?php endif; ?>></td>
                            </tr>
                            <tr>
                                <td width="15%"><label for="limit_price">有效期结束时间<em>*</em></label></td>
                                <td><input type="text" name="pend" class="u-ipt u-ipt-long" id="pend" placeholder="结束时间" value="<?php echo !empty($info['pend']) ? date('Y-m-d',$info['pend'])  :  date('Y-m-d', time()); ?>" <?php if($info['pend'] != ''): ?> readonly <?php else: ?> onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"<?php endif; ?>><span>默认到所选日期的23:59:59</span></td>
                            </tr>
                            <tr>
                                <td><label for="">分享图片</label></td>
                                <td>
                                    <button type="button" class="layui-btn u-upload-pic" data-name="share_img"><i class="layui-icon">&#xe67c;</i>上传图片</button>
                                    <div class="m-pic">
                                        <ul>
                                            <?php echo attach_html($info['share_img'], 'share_img'); ?>
                                        </ul>
                                    </div>
                                </td>
                            </tr>
                            <input type="hidden" value="<?php echo !empty($info['register_time']) ? htmlentities($info['register_time']) :  time(); ?>" name="register_time" id="register_time"/>
                        </tbody>
                    </table>
                    <div class="m-form-btn">
                        <input type="hidden" name="id" id="id" value="<?php echo htmlentities($info['id']); ?>">
                        <button id="j_btn" type="button" class="u-btn">确定提交</button></div>
                </form>
            </div>
        </div>
    </div>
</div>

<?php endif; ?>
<input type="hidden" name="action_uri" value="<?php echo url('action'); ?>" />

<input type="hidden" name="redirect_uri" value="<?php echo url('index'); ?>" />

<input type="hidden" name="region_uri" value="/manage/regions/regions" />
<script src="/static/public/js/jquery-1.10.2.js"></script>
<script src="/static/public/js/maniac.ui.js"></script>
<script src="/static/public/layui/layui.js" charset="utf-8"></script>
<script src="/static/public/js/aes.js"></script>
<script src="/static/public/js/mode-ecb-min.js"></script>
<script src="/static/public/js/utils.js"></script>
<script src="/static/public/js/dialog.js"></script>
<script src="/static/manage/js/form.js"></script>
<script src="/static/manage/js/js.js"></script>
<script src="/static/public/js/app.js"></script>
<script src="/static/public/js/encrypt.js"></script>
<script src="/static/public/dist/zoomify.min.js"></script>
<script type="text/javascript">
    $('.fdzoom').zoomify();
</script>

<script>
var aesKey = '<?php echo htmlentities($encrypt_key); ?>';
    $(function(){
        layui.use('layer', function(){
            var user_exists = parseInt('<?php echo !empty($user_exists) ? 1  :  0; ?>');
            var user_forbidden = parseInt('<?php echo !empty($user_forbidden) ? 1  :  0; ?>');
            var quit_force = parseInt('<?php echo !empty($quit_force) ? 1  :  0; ?>');
            var is_auth    = parseInt('<?php echo !empty($is_auth) ? 1  :  0; ?>');
            
            if (user_exists) {
                dialog.error('您所登录的用户已被删除', function(){
                	top.location.href = '/manage';
                    return false;
                });
            }
            
            if (user_forbidden) {
                dialog.error('您的账户已被禁用', function(){
                	top.location.href = '/manage';
                    return false;
                });
            }

            if (quit_force) {
                dialog.error('同一账户同一时间只能一人在线', function(){
                	top.location.href = '/manage';
                    return false;
                });
            }
            
            if (!is_auth) {
                dialog.error('您没有权限执行此操作', function(){
                    window.location.href = history.go(-1);
                    return false;
                });
            }
        });
    })
</script>

<script>

    /**

     * 上传图片

     * @param  {object}  uploader upload 对象

     * @param  {string}  ele      容器选择器

     * @param  {boolean} multiple 是否允许多图上传

     */

    function upload_pic(uploader, ele, multiple)

    {

        var signature = setSign();

        uploader.render({

            elem: ele,

            field: 'imgFile',

            multiple: multiple,

            url: '<?php echo url("/manage/upload/upload", ["path" => session("userid", "", session_prefix()), "type" => "image", "module" => request()->module() ?: "addons"]); ?>',

            headers: {signature: signature},

            done: function(ret){

                var index = dialog.loading();

                if (ret.status == 0) {

                    var name = $(this.item).attr('data-name');

                    // 上传完毕回调

                    if (multiple) {

                        // 上传多图
                        $(this.item).parent().find('.m-pics ul').append('<li><img src="' + ret.data.attach_uri + '" alt="" /><input type="hidden" name="' + name + '[desc][]" value="' + ret.data.id + '" /><a class="u-item"><i class="icon icon-remove"></i></a><input type="hidden" name="' + name + '[value][]" value="' + ret.data.id + '" /></li>');
                    } else {

                        // 上传单图

                        $(this.item).parent().find('.m-pic ul').html('<li><img src="' + ret.data.attach_uri + '" alt="" /><a class="u-item"><i class="icon icon-remove"></i></a><input type="hidden" name="' + name + '" value="' + ret.data.id + '" /></li>');

                    }

                    layer.close(index);

                } else {

                    dialog.error(ret.message);

                    layer.close(index);
                }
            }
        })
    }


    /**
     * 上传图片
     * @param  {object}  uploader upload 对象
     * @param  {string}  ele      容器选择器
     * @param  {boolean} multiple 是否允许多图上传
     */
    function sxupload_pic(uploader, ele, multiple)
    {
        var signature = setSign();
        uploader.render({
            elem: ele,
            field: 'imgFile',
            multiple: multiple,
            url: '<?php echo url("api/v1/upload", ["path" => session("userid", "", session_prefix()), "type" => "image", "module" => request()->module() ?: "addons"]); ?>',
            headers: {signature: signature},
            done: function(ret){
                var index = dialog.loading();
                if (ret.status == 0) {
                    var name = $(this.item).attr('data-name');
                    // 上传完毕回调
                    if (multiple) {
                        // 上传多图
                        $(this.item).parent().find('.m-pics ul').append('<li><img src="' + ret.data.attach_uri + '" alt="" /><a class="u-item"><i class="icon icon-remove"></i></a><input type="hidden" name="' + name + '[value][]" value="' + ret.data.id + '" /></li>');
                    } else {
                        // 上传单图
                        $(this.item).parent().find('.m-pic ul').html('<li><img src="' + ret.data.attach_uri + '" alt="" /><a class="u-item"><i class="icon icon-remove"></i></a><input type="hidden" name="' + name + '" value="' + ret.data.id + '" /></li>');
                    }
                    layer.close(index);
                } else {
                    dialog.error(ret.message);

                    layer.close(index);
                }

            }

        })

    }



    /**

     * 上传附件

     * @param  {object}  uploader upload 对象

     * @param  {string}  ele      容器选择器

     */

    function upload_file(uploader, ele)

    {

        uploader.render({

            elem: ele,

            field: 'imgFile',

            accept: 'file',

            url: '<?php echo url("manage/upload/filemanager", ["path" => session("userid", "", session_prefix()), "type" => "file", "module" => request()->module() ?: "addons"]); ?>',

            done: function(ret){

                var index = dialog.loading();

                if (ret.status == 0) {

                    var name = $(this.item).attr('data-name');

                    // 上传完毕回调

                    $(this.item).parent().find('.m-files ul').append('<li><i class="icon-paper-clip"></i><input type="text" name="'+name+'[name][]" value="' + ret.data.title + '" /><a data-md5-file="' + ret.data.md5_file + '" data-id="' + ret.data.id + '" class="u-download">下载</a><a class="u-item" data-id="' + ret.data.id + '">删除</a><input type="hidden" name="' + name + '[value][]" value="' + ret.data.id + '" /></li>');

                    $(this.item).parent().find('.m-files').show();

                    layer.close(index);

                } else {

                	

                    dialog.error(ret.message);



                    layer.close(index);

                }

            }

        })

    }



    layui.use(['upload'], function(ele, multiple){

        // 得到 upload 对象

        var upload = layui.upload;

        // 上传单图

        upload_pic(upload, '.u-upload-pic', false);

        // 上传多图

        upload_pic(upload, '.u-upload-pics', true);

        // 上传附件

        upload_file(upload, '.u-upload-file');

        //双喜
        sxupload_pic(upload, '.sxu-upload-pic', false);
        sxupload_pic(upload, '.sxu-upload-pics', true);
    });

</script>
<script src="/static/public/js/jquery-ui.min.js"></script>
<script>
    $(function () {
        var keyValue;
        keyValue = $("input[name='coupon_type']:checked").val();

        if (keyValue == 0) {
            $("#fl").hide();
            $("#sp").hide();
        }
        if (keyValue == 1) {
            $("#fl").show();
            $("#sp").hide();
        }
        if (keyValue == 2) {
            $("#fl").hide();
            $("#sp").show();
        }
    })
    layui.use('form', function () {
        var form = layui.form;
        form.on('radio(coupon_type)', function (data) {
            if (data.value == 0) {
                $("#fl").hide();
                $("#sp").hide();
            }
            if (data.value  == 1) {
                $("#fl").show();
                $("#sp").hide();
            }
            if (data.value  == 2) {
                $("#fl").hide();
                $("#sp").show();
            }
            form.render();
        });
        form.on('radio(commission_charge_type)', function (data) {
            if (data.value == 0) {
                $('.commission_charge_first').attr("disabled",true);
                $('.commission_charge_second').attr("disabled",true);
            }
            if (data.value  == 1) {
                $('.commission_charge_first').attr("disabled",false);
                $('.commission_charge_second').attr("disabled",false);
            }
            if (data.value  == 2) {
                $('.commission_charge_first').attr("disabled",false);
                $('.commission_charge_second').attr("disabled",false);
            }
            form.render();
        });
    });
</script>

</body>
</html>